

import 'dart:ffi';

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get/get_state_manager/get_state_manager.dart';
import 'package:jydoctorflutter/net/api.dart';
import 'package:jydoctorflutter/pages/login/send_code/view.dart';
import 'package:jydoctorflutter/utils/tools/toast.dart';
import 'package:jydoctorflutter/utils/tools/toast_extension.dart';

import '../../routes/routes.dart';
import 'obtain_ticket_webPage.dart';

class LoginVC extends GetxController {


    RxBool isselect = false.obs;
    String orderlyId = "123";
    String telephoneNUm = "";

    RxString result = ''.obs;

    void init(){
        orderlyId = "q";
    }
    @override
    void onInit(){
        print("来一次");
        // ever 就能正常监听到路由变化了
        ever(Get.routing.obs, (route)  {
            print('当前路由是: ${route.current}');
            print('上一个路由是: ${route.previous}');
            if (route.current == '/LoginVC'){

            }
        });

        ever(isselect, (value) => {

        });
        ever(result, (value) => {
        print('当前result是: ${result}')
        });
    }

    @override
    void onReady() {
        super.onReady();
        // 这里可以放置类似于 viewDidAppear 的代码

    }

    Future<void> clickPra() async{
        isselect.value = !isselect.value;
    }
    void gotoSendCode(){
        if (!isselect.value){
            ('请同意协议').toast();
            return ;
        }
        if (telephoneNUm.length < 11) {
            ('请输入正确手机号').toast();
            return ;
        }
        Map<String, dynamic> params = {
            "telephone": telephoneNUm,
        };
        // Toast.showHUD();
        Api.checkPhoneNumber(params).then((onValue) async {
            sendGoView();
        }).catchError((onError) {
            "数据错误".toast();
        });
        // Get.to(obtainTicketWebPage());
       //全屏设置--调用次方法
       //  Get.generalDialog(
       //      barrierDismissible: true,
       //      barrierLabel: "Dismiss", // 这里补上！
       //      pageBuilder: (context, animation, secondaryAnimation) {
       //          return Scaffold(
       //              body: obtainTicketWebPage(), // 这里就是全屏了
       //          );
       //      },
       //  );
    }
        void sendGoView(){
            Get.toNamed(Routes.SendCodePage,arguments: {'telephone': telephoneNUm});
    }
}

